﻿@model MemberPoint.Entity.ViewModels.ShopViewModel.CreateShopViewModel

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>EditShopInfo</title>
    <script src="~/scripts/easy-ui/jquery-1.11.1.js"></script>
    <link href="~/Content/easy-ui/default/easyui.css" rel="stylesheet" />
    <script src="~/scripts/easy-ui/jquery.easyui.min.js"></script>
    <link href="~/Content/easy-ui/icon.css" rel="stylesheet" />
</head>
<body>
    @using (Html.BeginForm("Edit", "Shop", FormMethod.Post, new { id = "form_Shops" }))
    {
        <div>
            <table align="center">
                <tr>
                    <td style="text-align:right">店铺名称：</td>
                    <td style="text-align:left">
                        @Html.EditorFor(model => model.S_Name, new { htmlAttributes = new { @id = "txtshopname" } })
                        @Html.ValidationMessageFor(model => model.S_Name, "", new { @class = "text-danger" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right">店铺类型：</td>
                    <td style="text-align:left">
                        @Html.DropDownListFor(model=>model.S_Category, ViewBag.ShopType as IEnumerable<SelectListItem>, new { @class = "easyui - combobox" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right">联系人：</td>
                    <td style="text-align:left">
                        @Html.EditorFor(model => model.S_ContactName, new { htmlAttributes = new { @id = "txtlinkman" } })
                        @Html.ValidationMessageFor(model => model.S_ContactName, "", new { @class = "text-danger" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right">联系电话：</td>
                    <td style="text-align:left">
                        @Html.EditorFor(model => model.S_ContactTel, new { htmlAttributes = new { @id = "txtlinkmantel" } })
                        @Html.ValidationMessageFor(model => model.S_ContactTel, "", new { @class = "text-danger" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right">店铺地址：</td>
                    <td style="text-align:left">
                        @Html.EditorFor(model => model.S_Address, new { htmlAttributes = new { @id = "txtshopadd" } })
                        @Html.ValidationMessageFor(model => model.S_Address, "", new { @class = "text-danger" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right">备注：</td>
                    <td style="text-align:left">
                        @Html.EditorFor(model => model.S_Remark, new { htmlAttributes = new { @id = "txtremark" } })
                        @Html.ValidationMessageFor(model => model.S_Remark, "", new { @class = "text-danger" })
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align:center">
                        <a href="javascript:" id="btn" class="easyui-linkbutton">提交</a>
                    </td>
                </tr>
            </table>
            @*隐藏域存放id*@
            @Html.HiddenFor(model => model.S_ID, new { htmlAttributes = new { id = "S_ID" } })
        </div>
    }
    <script>
        $(function () {
            $('#btn').linkbutton({
            });
            var postUrl = "";
            $("#btn").click(function () {
                if (parseInt($("#S_ID").val()) > 0) {
                    postUrl = "/Shop/EditShop/" + parseInt($("#S_ID").val())
                } else {
                    postUrl = "/Shop/CreateShop";
                }

                $("#form_Shops").form("submit", {
                    url: postUrl,
                    onSubmit: function () {
                        var isValid = $(this).form("validate");
                        return isValid;
                    },
                    success: function (data) {
                        var json = JSON.parse(data);
                        if (json.ResultStatus == 1) {
                            //提示消息
                            window.parent.$.messager.alert('温馨提示', json.Msg, 'info');
                            //关闭弹窗
                            window.parent.$("#editshop").dialog("close");
                            //刷新列表
                            window.parent.$("#shoptable").datagrid("reload");
                        }
                        else {
                            $.messager.alert("温馨提示", json.Msg, "error");
                        }
                    }
                })
            })
        })
    </script>
</body>
</html>
